package temp;

import org.apache.logging.log4j.Logger;

import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
import java.util.List;

/**
 * 09.11.14
 *
 * @author horec
 */
@Named
@RequestScoped
public class ReaderController {
    @Inject
    private Logger log;
    @Inject
    @WidgetRepository
    private EntityManager widgetRepository;

    private List<Reader> readers;

    @PostConstruct
    public void loadReaders(){
        //noinspection unchecked
        readers = widgetRepository.createQuery("select r from Reader r").getResultList();
    }

    public List<Reader> getReaders() {
        return readers;
    }
}
